$(function() {
  if ($('#product-pagination').size() > 0) {
    return $(document).on('scroll', function() {
      var more_posts_url;
      /*more_posts_url = $('.pagination .next_page a').attr('href');*/
      more_posts_url =  $('.pagination .next_page').attr('href').replace("all=true&","");
      if (more_posts_url && $(window).scrollTop() > $(document).height() - $(window).height() - 300) {
        $('.pagination').html('<img src="../images/pagination-loader.gif" alt="Cargando..." title="Cargando..." />');
        $.getScript(more_posts_url);
      }
      return;
    });
  }
});